/**
 * 继承BaseScene类的一个示例;
 */
import {global} from '../Main';
import {BaseScene} from 'BaseScene';
export class Demo1 extends BaseScene{
    /**
     * 只需要实现此方法，将playground的代码粘贴到此方法即可;
     * @returns
     */
    public iniScene(){
        //注意添加这两行，以匹配playground里的代码
        var engine = global.engine;
        var canvas = global.canvas;
        var scene = this.scene;

        var camera = new BABYLON.ArcRotateCamera("arc1", -Math.PI / 4, Math.PI / 4, 40, BABYLON.Vector3.Zero(), scene);
        camera.lowerRadiusLimit = 0;
        camera.attachControl(canvas, true);

        var light = new BABYLON.PointLight("light", new BABYLON.Vector3(0, 0, 0), scene);
        light.specular = new BABYLON.Color3(0, 0, 0);
        light.diffuse = new BABYLON.Color3(1, 1, 1);
        light.intensity = 0.7;


        var house = BABYLON.MeshBuilder.CreateBox("house", { width: 30, height: 15, depth: 20, sideOrientation: BABYLON.Mesh.BACKSIDE }, scene);
        

        var doorL = BABYLON.MeshBuilder.CreateBox("Demo1_doorL", { width: 0.1, height: 5, depth: 3 }, scene);
        var doorMaterial = new BABYLON.StandardMaterial("door", scene);
        doorMaterial.diffuseTexture = new BABYLON.Texture("https://minio.cnbabylon.com/babylon/p11/crate.png", scene);
        doorL.material = doorMaterial;
        doorL.position = new BABYLON.Vector3(-14.9, -5, 0);
        // var dLPlane = BABYLON.MeshBuilder.CreatePlane("dLPlane", {size: 2}, scene);
        // dLPlane.position = doorL.position;
        // dLPlane.rotation = new BABYLON.Vector3(0, Math.PI/2, 0);

        var doorR = doorL.clone("doorR");
        doorR.id = "doorR";
        doorR.position = new BABYLON.Vector3(14.9, -5, 0);
        // var dRPlane = BABYLON.MeshBuilder.CreatePlane("dRPlane", {size: 2}, scene);
        // dRPlane.position = doorR.position;
        // dRPlane.rotation = new BABYLON.Vector3(0, Math.PI/2, 0);



        // var glbDemo = BABYLON.SceneLoader.Append("glb/", "table.gltf", scene, (scene) => {
        //     var mesh = <BABYLON.Mesh>scene.getMeshByID('立方体.001');
        //     mesh.position = new BABYLON.Vector3(0,-4,0);
        //     this.clickToRender3D(mesh, SCENE.MainScene);
        // });

        house.isPickable = false;
        doorL.isPickable = false;
        doorR.isPickable = false;

        this.clickToRender3D(doorL, SCENE.MainScene);
        this.clickToRender3D(doorR, SCENE.Demo2);



    }

}
// /**
//  * 3d地图;
//  */
// var createDemo1Scene = function () {
//     var engine = global.engine;
//     var canvas = global.canvas;

//     var scene = new BABYLON.Scene(engine);
//     var camera = new BABYLON.ArcRotateCamera("arc1", -Math.PI / 4, Math.PI / 4, 40, BABYLON.Vector3.Zero(), scene);
//     camera.lowerRadiusLimit = 0;
//     camera.attachControl(canvas, true);

//     var light = new BABYLON.PointLight("light", new BABYLON.Vector3(0, 0, 0), scene);
//     light.specular = new BABYLON.Color3(0, 0, 0);
//     light.diffuse = new BABYLON.Color3(1, 1, 1);
//     light.intensity = 0.7;


//     var house = BABYLON.MeshBuilder.CreateBox("house", { width: 30, height: 15, depth: 20, sideOrientation: BABYLON.Mesh.BACKSIDE }, scene);
    

//     var doorL = BABYLON.MeshBuilder.CreateBox("Demo1_doorL", { width: 0.1, height: 5, depth: 3 }, scene);
//     var doorMaterial = new BABYLON.StandardMaterial("door", scene);
//     doorMaterial.diffuseTexture = new BABYLON.Texture("https://minio.cnbabylon.com/babylon/p11/crate.png", scene);
//     doorL.material = doorMaterial;
//     doorL.position = new BABYLON.Vector3(-14.9, -5, 0);
//     // var dLPlane = BABYLON.MeshBuilder.CreatePlane("dLPlane", {size: 2}, scene);
//     // dLPlane.position = doorL.position;
//     // dLPlane.rotation = new BABYLON.Vector3(0, Math.PI/2, 0);

//     var doorR = doorL.clone("doorR");
//     doorR.id = "doorR";
//     doorR.position = new BABYLON.Vector3(14.9, -5, 0);
//     // var dRPlane = BABYLON.MeshBuilder.CreatePlane("dRPlane", {size: 2}, scene);
//     // dRPlane.position = doorR.position;
//     // dRPlane.rotation = new BABYLON.Vector3(0, Math.PI/2, 0);



//     var glbDemo = BABYLON.SceneLoader.Append("glb/", "chair.glb", scene, (scene) => {
//         var mesh = <BABYLON.Mesh>scene.getMeshByID('立方体.002');
//         mesh.position = new BABYLON.Vector3(0,-4,0);
        
//         clickToRender3D(mesh, SCENE.Demo1, SCENE.MainScene);
//     });

//     house.isPickable = false;
//     doorL.isPickable = false;
//     doorR.isPickable = false;


//     clickToRender3D(doorL, SCENE.Demo1, SCENE.MainScene);
//     clickToRender3D(doorR, SCENE.Demo1, SCENE.Demo2);
//     // clickToRender(dLPlane, SCENE.MainScene);
//     // clickToRender(dRPlane, SCENE.Demo2);





//     return scene;
// };